<template>
	<view id="account-register">
		<view class="common-form1">
			<view class="item">
				<view class="label">用户帐号</view>
				<view class="content">
					<input class="uni-input" v-model="formData.nick_name" name="input" placeholder="这是一个输入框" />
				</view>
			</view>
			<view class="item">
				<view class="label">用户密码</view>
				<view class="content">
					<input class="uni-input" v-model="formData.password" name="input" placeholder="这是一个输入框" />
				</view>
			</view>
			<view class="item">
				<view class="label">确认密码</view>
				<view class="content">
					<input class="uni-input" v-model="cfmPassword" name="input" placeholder="这是一个输入框" />
				</view>
			</view>
			<view class="item">
				<view class="label">密保问题</view>
				<view class="content">
					<input class="uni-input" v-model="formData.account_safety_question" @click="safetyFn" :disabled="questionStatus" name="input" placeholder="这是一个输入框" />
				</view>
			</view>
			<view class="item">
				<view class="label">密保答案</view>
				<view class="content">
					<input class="uni-input" v-model="formData.account_safety_answer" name="input" placeholder="这是一个输入框" />
				</view>
			</view>
		</view>
		
		<view id="account-register-dialog" v-if="show">
			<scroll-view class="content" scroll-y>
				<view class="item" v-for="(item, index) in safetyArr" :key="index" @click="dialogItem(item)">{{item}}</view>
			</scroll-view>
		</view>
		<button class="register" type="primary" @click="registerFn">注册</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				safetyArr: [
					"你父母的姓名",
					"你的生日",
					"你毕业于那所初中",
					"你喜欢看的电影",
					"你毕业于那所大学",
					"你配偶姓名",
					"你最喜欢的人",
					"你的学号",
					"你父母生日",
					"你的出生地",
					// "自定义密保问题",
				],
				questionStatus: true,
				show: false,
				cfmPassword: '',
				formData: {
					nick_name: '',
					password: '',
					account_safety_question: '',
					account_safety_answer: ''
				}
			}
		},
		onLoad() {
			// this.init()

			// uni.redirectTo({
			// 	url: '../../pages/index/detail?params=' + JSON.stringify(item)
			// });
		},
		methods: {
			safetyFn() {
				if(this.questionStatus) {
					this.show = true
				}
			},
			dialogItem(data) {
				console.log(data)
				// if(data !== "自定义密保问题") {
				// 	this.formData.account_safety_question = data
				// } else {
				// 	this.questionStatus = false
				// 	this.formData.account_safety_question = ""
				// }
				this.formData.account_safety_question = data
				this.show = false
			},
			init() {
				// console.log(window.localStorage.getItem("USER_INFO_DATA"))
				uni.getStorage({
					key: 'USER_INFO-DATA',
					success: function(res) {
						console.log(res);
					}
				});
			},
			registerFn() {
				console.log(this.formData)
			}
		}
	}
</script>

<style>
	
</style>
